package clientGUI.userPanels;

import college.User;
import clientGUI.userPanels.Controllers.SupervisorController;
import clientserver.Client;

import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class SupervisorPLTimelimitPanel extends UPanel {
	SupervisorController controller;
	User currentUser;
	private JTextField startDateTxt;
	private JTextField endateTxt;
	private JTextField reqIDTxt;
	
	
	public SupervisorPLTimelimitPanel(int rid, Client cl) {
		setLayout(null);
		
		controller = new SupervisorController(cl,rid);
		
		JLabel lblProcessLeaderTimelimit = new JLabel("PROCESS LEADER TIMELIMIT APPROVAL");
		lblProcessLeaderTimelimit.setBounds(135, 11, 215, 14);
		add(lblProcessLeaderTimelimit);
		
		JLabel lblCurrentEndDate = new JLabel("Current end date:");
		lblCurrentEndDate.setBounds(47, 94, 101, 14);
		add(lblCurrentEndDate);
		
		
		startDateTxt = new JTextField(controller.getCurrentStartDate().toString());
		startDateTxt.setBounds(248, 91, 86, 20);
		add(startDateTxt);
		startDateTxt.setColumns(10);
		
		JLabel lblCurrentStartDate = new JLabel("Current Start Date:");
		lblCurrentStartDate.setBounds(47, 146, 109, 14);
		add(lblCurrentStartDate);
		
		endateTxt = new JTextField(controller.getCurrentEndDate().toString());
		endateTxt.setBounds(248, 143, 86, 20);
		add(endateTxt);
		endateTxt.setColumns(10);
		
		JLabel lblRequest = new JLabel("Request ID :");
		lblRequest.setBounds(47, 56, 74, 14);
		add(lblRequest);
		
		reqIDTxt = new JTextField(rid);
		reqIDTxt.setBounds(248, 53, 86, 20);
		add(reqIDTxt);
		reqIDTxt.setColumns(10);
		
		JButton btnApprove = new JButton("Approve");
		btnApprove.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				controller.approvedProcessLeaderTimelimit();
				myframe.SetMainUserPanel();
			}
		});
		btnApprove.setBounds(47, 217, 91, 23);
		add(btnApprove);
		
		JButton btnDisapprove = new JButton("Disapprove");
		btnDisapprove.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				controller.disapproveProcessLeaderTimelimit();
				myframe.SetMainUserPanel();
			}
		});
		btnDisapprove.setBounds(267, 217, 91, 23);
		add(btnDisapprove);
		
		JButton btnMainMenu = new JButton("Main Menu");
		btnMainMenu.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) 
			{
				myframe.SetMainUserPanel();
			}
		});
		btnMainMenu.setBounds(163, 266, 89, 23);
		add(btnMainMenu);
	}
	
	

}
